from flask import Flask

from apps.api.test1 import test_bp
from apps.api.user_api import user_bp
from apps.api.a import test_bp1
from apps.api.frist import first_bp
from apps.api.fault_record import record_bp
from exts import db, cors, cache
from settings import DevelopmentConfig

config = {
    'CACHE_TYPE': 'redis',
    'CACHE_REDIS_HOST': '127.0.0.1',
    'CACHE_REDIS_PORT': 6379
}


def create_app():
    app = Flask(__name__, static_folder='../static')
    app.config.from_object(DevelopmentConfig)

    db.init_app(app=app)
    cors.init_app(app=app)
    cache.init_app(app=app, config=config)
    app.register_blueprint(test_bp)
    app.register_blueprint(user_bp)
    app.register_blueprint(test_bp1)
    app.register_blueprint(first_bp)
    app.register_blueprint(record_bp)

    return app
